// BattLineCabDLL.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"

BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
  return TRUE;
}

codeINSTALL_INIT Install_Init(HWND hwndParent, BOOL fFirstCall, BOOL fPreviouslyInstalled, LPCTSTR pszInstallDir)
{
  return codeINSTALL_INIT_CONTINUE;
}

codeINSTALL_EXIT Install_Exit(HWND hwndParent, LPCTSTR pszInstallDir, WORD cFailedDirs, WORD cFailedFiles, WORD cFailedRegKeys, WORD cFailedRegVals, WORD cFailedShortcuts)
{
  ActivateService(_T("BattLineSvc"),0);
  return codeINSTALL_EXIT_DONE;
} 

codeUNINSTALL_INIT Uninstall_Init(HWND hwndParent, LPCTSTR pszInstallDir)
{
  HANDLE hsvc = GetServiceHandle(_T("BLS0:"), NULL, 0);
  if (hsvc != INVALID_HANDLE_VALUE)
  {
    DeregisterService(hsvc);
  }

  return codeUNINSTALL_INIT_CONTINUE;
} 

codeUNINSTALL_EXIT Uninstall_Exit(HWND hwndParent)
{
  if (MessageBox(hwndParent, L"It is *HIGHLY* recommended that you soft reset your device after uninstalling BattLineSvc. If you are installing a BattLineSvc upgrade, you can wait until after the cab finishes the installation, but you should soft reset after that. Would you like to soft reset now?", L"BattLineSvc Installer", MB_YESNO) == IDYES)
  {
    ExitWindowsEx(EWX_REBOOT, 0);
  }
  return codeUNINSTALL_EXIT_DONE;
}